#include <stdio.h>
#include <iostream>
#include <string>
#include <map>
using namespace std;
int  num[26];

map<string,string> word;
map<string,string>::iterator pos;
string str1 , str2;

main()
{
//	 freopen("input2", "r", stdin);
  // freopen("output", "w",stdout);
	char ss[50], s1[11], s2[11],ch ;
	int a,b,i,j;


	while (gets(ss))
	{
		while (strlen(ss)==0) gets(ss);
		if (strstr(ss," ")==0) break;
		sscanf(ss,"%s %s", s1, s2);
		str1 = s1;
		str2 = s2;
		word[str2] = str1;
	} 

	sscanf(ss,"%s", s1);
	do 
	{
		while (strlen(s1)==0) gets(s1);
		pos = word.find(s1);
		
		if (pos == word.end() ) cout << "eh" << endl;
		else  cout << pos->second << endl;
		
	} while(gets(s1));


	return 0;
}
